import Vue from 'vue'
import Router from 'vue-router'
import home from '@/view/home'
import product from '@/view/product'
import zannue from '@/view/zannue'
import about from '@/view/about'
import lianxi from '@/view/lianxi'
import yanfa from '@/view/yanfa'
import news from '@/view/news'
import newsDetails from '@/view/news-details'
import licheng from '@/view/about/licheng'
import chanye from '@/view/about/chanye'
import jianjie from '@/view/about/jianjie'
import wenhua from '@/view/about/wenhua'
import school from '@/view/zannue/school'
import society from '@/view/zannue/society'
import productDetails from '@/view/product-details'
import chanyeDetails from '@/view/chanye-details'
// import sliderHome from '@/view/sliderHome'

Vue.use(Router)

// Router.beforeEach((to, from, next) => {
//   if (to.fullPath === '/') {
//     from.name ? next({ name:from.name }) : next('/home')
//   } else {
//     next()
//   }
// })

export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: home
    },
    {
      path: '/product',
      name: 'product',
      component: product
    },
    {
      path: '/zannue',
      name: 'zannue',
      redirect: '/society',
      component: zannue,
      children: [
        {
          path: '/school',
          name: 'school',
          component: school
        },
        {
          path: '/society',
          name: 'society',
          component: society
        }
      ]
    },
    {
      path: '/about',
      name: 'about',
      redirect: '/jianjie',
      component: about,
      children: [
        {
          path: '/jianjie',
          name: 'jianjie',
          component: jianjie
        },
        {
          path: '/licheng',
          name: 'licheng',
          component: licheng
        },
        {
          path: '/chanye',
          name: 'chanye',
          component: chanye
        },
        {
          path: '/wenhua',
          name: 'wenhua',
          component: wenhua
        }
      ]
    },
    {
      path: '/lianxi',
      name: 'lianxi',
      component: lianxi
    },
    {
      path: '/yanfa',
      name: 'yanfa',
      component: yanfa
    },
    {
      path: '/news',
      name: 'news',
      component: news
    },
    {
      path: '/productDetails/:id',
      name: 'productDetails',
      component: productDetails
    },
    {
      path: '/newsDetails/:id',
      name: 'newsDetails',
      component: newsDetails
    },
    {
      path: '/chanyeDetails/:id',
      name: 'chanyeDetails',
      component: chanyeDetails
    }
  ]
})
